﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using NFLDriver;

namespace WcfServiceTransLayer
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
    public class Service1 : MyWCFService
    {
        DriverLogic drLogic = new DriverLogic();

        public serviceTeam getServiceTeam(int index)
        {
            serviceTeam tempServTeam = new serviceTeam();
            //string tempGuid = drLogic.getTeams().getTeam(index).teamId.ToString();
            //tempServTeam.teamId = tempGuid;
            tempServTeam.teamName = drLogic.getTeams().getTeam(index).teamName;
            tempServTeam.winLossCode0 = drLogic.getTeams().getTeam(index).getScore(0);
            tempServTeam.winLossCode1 = drLogic.getTeams().getTeam(index).getScore(1);
            tempServTeam.winLossCode2 = drLogic.getTeams().getTeam(index).getScore(2);
            tempServTeam.winLossCode3 = drLogic.getTeams().getTeam(index).getScore(3);
            tempServTeam.winLossCode4 = drLogic.getTeams().getTeam(index).getScore(4);
            tempServTeam.winLossCode5 = drLogic.getTeams().getTeam(index).getScore(5);
            tempServTeam.winLossCode6 = drLogic.getTeams().getTeam(index).getScore(6);
            tempServTeam.winLossCode7 = drLogic.getTeams().getTeam(index).getScore(7);
            tempServTeam.winLossCode8 = drLogic.getTeams().getTeam(index).getScore(8);
            tempServTeam.winLossCode9 = drLogic.getTeams().getTeam(index).getScore(9);
            tempServTeam.winLossCode10 = drLogic.getTeams().getTeam(index).getScore(10);
            tempServTeam.winLossCode11 = drLogic.getTeams().getTeam(index).getScore(11);
            tempServTeam.winLossCode12 = drLogic.getTeams().getTeam(index).getScore(12);
            tempServTeam.winLossCode13 = drLogic.getTeams().getTeam(index).getScore(13);
            tempServTeam.winLossCode14 = drLogic.getTeams().getTeam(index).getScore(14);
            tempServTeam.winLossCode15 = drLogic.getTeams().getTeam(index).getScore(15);
            tempServTeam.winLossCode16 = drLogic.getTeams().getTeam(index).getScore(16);


            return tempServTeam;

        }

        /*
        serviceUser getUser(serviceUser user)
        {

        }
        */

        public void createUserAccount(serviceUser user)
        {
            User tempUser = new User(user.FirstName, user.LastName, user.Email, user.Password);
            drLogic.createUserAccount(tempUser);
        }

        public serviceUser login(serviceUser user)
        {
            serviceUser returnUser = new serviceUser();
            User conversionUser;
            User tempUser = new User(user.FirstName, user.LastName, user.Email, user.Password);
            conversionUser = drLogic.login(tempUser);
            returnUser.FirstName = conversionUser.FirstName;
            returnUser.LastName = conversionUser.LastName;
            returnUser.Email = conversionUser.Email;
            returnUser.loggedIn = conversionUser.loggedIn();
            returnUser.Password = conversionUser.Password;
            returnUser.SelectedTeam0Name = conversionUser.getSelectedTeam(0).teamName;
            returnUser.SelectedTeam1Name = conversionUser.getSelectedTeam(1).teamName;
            returnUser.SelectedTeam2Name = conversionUser.getSelectedTeam(2).teamName;
            returnUser.SelectedTeam3Name = conversionUser.getSelectedTeam(3).teamName;
            returnUser.SelectedTeam4Name = conversionUser.getSelectedTeam(4).teamName;
            returnUser.SelectedTeam5Name = conversionUser.getSelectedTeam(5).teamName;
            returnUser.SelectedTeam6Name = conversionUser.getSelectedTeam(6).teamName;

            return returnUser;


        }

        public void updateUserSelectedTeams(serviceUser user)
        {
            User tempUser = new User(user.FirstName, user.LastName, user.Email, user.Password);
            for (int i = 0; i < 7; i++)
            {
                tempUser.setSelectedTeam(i, new Team());
            }
            tempUser.getSelectedTeam(0).teamName = user.SelectedTeam0Name;
            tempUser.getSelectedTeam(1).teamName = user.SelectedTeam1Name;
            tempUser.getSelectedTeam(2).teamName = user.SelectedTeam2Name;
            tempUser.getSelectedTeam(3).teamName = user.SelectedTeam3Name;
            tempUser.getSelectedTeam(4).teamName = user.SelectedTeam4Name;
            tempUser.getSelectedTeam(5).teamName = user.SelectedTeam5Name;
            tempUser.getSelectedTeam(6).teamName = user.SelectedTeam6Name;

            drLogic.updateUserSelectedTeams(tempUser);
             
        }




        /*
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }
        */
        /*
        public CompositeType GetDataUsingDataContract(CompositeType composite)
        {
            if (composite == null)
            {
                throw new ArgumentNullException("composite");
            }
            if (composite.BoolValue)
            {
                composite.StringValue += "Suffix";
            }
            return composite;
        }
        */ 
    }
}
